import type { User, Code, UserInfo, PatientList, Patient } from '@/types/user'
import { request } from '@/utils/request'

/**
 * 密码登录
 * @param mobile
 * @param password
 */
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('/login/password', 'POST', { mobile, password })

/**
 * 获取手机验证码
 * @param mobile 手机号
 * @param type 验证码类型
 */
export const sendMobileCode = (mobile: string, type: Code) =>
  request('/code', 'GET', { mobile, type })

/**
 * 登录--手机验证码登录
 * @param mobile
 * @param code
 */
export const loginByCode = (mobile: string, code: string) =>
  request<User>('/login', 'POST', { mobile, code })

/**
 * 获取个人用户信息
 */
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

export const getPatientList = () => request<PatientList>('/patient/mylist')
